import './index.scss'
import { useDispatch } from 'react-redux'
import { addCartList ,subCartList} from '../../store/modules/takeaway'
const Count = ({  count , id }) => {
  const dispatch = useDispatch()
  const onMinus = () => {
     dispatch(subCartList({id,count :count-1, }))
  }
  const onPlus = () => {
    dispatch(addCartList({id,count}))
     
  }
  return (
    <div className="goods-count">
      <span className="minus sub-icon" onClick={onMinus}></span>
      <span className="count">{count}</span>
      <span className="plus add-icon" onClick={onPlus}></span>
    </div>
  )
}

export default Count
